package com.example.zpositionanimationdemo.chechbox;

import ohos.agp.render.Path;

public class ClipPathManager {
    protected final Path path = new Path();

    /**
     * ClipPathManager
     */
    public ClipPathManager() {
    }

    /**
     * 设置裁剪布局
     *
     * @param width 宽
     * @param height 高
     */
    public void setupClipLayout(int width, int height) {
        path.reset();
        Path clipPath = null;
        if (createClipPath != null) {
            clipPath = createClipPath.createClipPath(width, height);
        }
        if (clipPath != null) {
            path.set(clipPath);
        }
    }

    /**
     * 设置裁剪路径
     *
     * @return Path
     */
    public Path getClipPath() {
        return path;
    }

    private ClipPathCreator createClipPath = null;

    public void setClipPathCreator(ClipPathCreator cLipPath) {
        this.createClipPath = cLipPath;
    }

    /**
     * ClipPathCreator
     */
    public interface ClipPathCreator {
        Path createClipPath(int width, int height);
    }
}
